home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # unmount-all-images
- # copyleft (c) 2000, joseph cheek, joseph@lycoris.com. released under GPL.
- #
- # unmount-all-images:
- # unmount all of the (cd, floppy, ramdisk) images from a build in the
- # current build directory that were mounted by the mount-all-images command.
- #
- # ex: unmount-all-images
- #
-
- MNT="/opt/redmondlinux/builds/mnt"
-
- if [ ! -f /tmp/initrd..new ]; then
- echo /tmp/initrd..new does not exist\!
- echo exiting . . .
- exit 1
- fi
-
-
- #
- #
- # unmount initrd images from cd and install, copy back to appropriate
- # places
-
- for a in cd install; do
-
- echo $a:
- dir -l "$MNT"/$a/initrd.gz
-
- # first create new ext2 filesystems
-
- cp /tmp/initrd.{,$a}.new
-
- # mount the new filesystem, remove lost+found
-
- mount -o loop /tmp/initrd.$a.new "$MNT"/${a}_ramdisk.new/
- rmdir "$MNT"/${a}_ramdisk.new/lost+found
-
- # first use old initrd's
- # mount the new filesystem, remove files
-
- # mount -o loop /tmp/initrd.$a.orig "$MNT"/${a}_ramdisk.new/
- # rm -rf "$MNT"/${a}_ramdisk.new/*
-
- df -k "$MNT"/${a}_ramdisk
-
- # copy over all files [gets rid of garbage laying around in ext2]
- cp -a "$MNT"/${a}_ramdisk/.profile "$MNT"/${a}_ramdisk/* \
- "$MNT"/${a}_ramdisk.new/
-
- echo after copy:
- df -k "$MNT"/${a}_ramdisk.new
-
- # unmount the images
- umount "$MNT"/${a}_ramdisk{,.new} ||
- echo -e ${a}_ramdisk unmount failed\\a
-
- # then write their contents back to the proper initrd.gz files
-
- # comment next line to stop copy of initrd back to floppy images
- gzip -9 -c /tmp/initrd.$a.new > "$MNT"/$a/initrd.gz
- gzip -9 -c /tmp/initrd.$a.new > /tmp/initrd.$a.gz # second copy for testing
- dir -l "$MNT"/$a/initrd.gz
- df -k "$MNT"/$a
- echo
-
- # then remove the immutable bit [bug: assumes ext2 filesystem]
- chattr -i /tmp/initrd.$a
-
- # remove the files we used
- rm /tmp/initrd.$a{,.gz,.orig}
-
- done
-
- for a in pcmcia; do
-
- # first create new ext2 filesystems
-
- dd if=/dev/zero of=/tmp/$a.new bs=1k count=1440
- mke2fs -q -m 0 -F -N 200 /tmp/$a.new
-
- # mount the new filesystem, remove lost+found
-
- mount -o loop /tmp/$a.new "$MNT"/${a}.new/
- rmdir "$MNT"/${a}.new/lost+found
-
- # copy over all files [gets rid of garbage laying around in ext2]
- cp -a "$MNT"/${a}/* "$MNT"/${a}.new/
-
- # unmount the images
- umount "$MNT"/${a}{,.new} ||
- echo -e ${a} unmount failed\\a
-
- # update original file
- mv /tmp/${a}.144{,.orig}
- mv /tmp/${a}.{new,144}
- fup /tmp/${a}.144 floppy
- mv /tmp/${a}.144{.orig,}
-
- done
-
-
- #
- #
- # unmount ext2 files under loopback
-
- umount "$MNT"/cd ||
- echo -e cd unmount failed\\a
-
- umount "$MNT"/install ||
- echo -e install unmount failed\\a
-
- umount "$MNT"/scsi ||
- echo -e scsi unmount failed\\a
-
-
- #
- #
- # show mounts remaining
-
- df -h
-